//@dart=2.12
import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/bad_event/view_model/event_archiving_view_model.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/widgets/common_widget.dart';

class EventArchivingSheet extends BaseStatefulMvvmWidget {
  dynamic id;

  EventArchivingSheet({required this.id});

  @override
  State<StatefulWidget> createState() => _EventArchivingState();
}

Future<dynamic> showEventArchivingSheet(BuildContext context,
    {required dynamic id}) async {
  return await showModalBottomSheet(
      context: context,
      builder: (context) {
        return EventArchivingSheet(id: id);
      },
      backgroundColor: Colors.transparent);
}

class _EventArchivingState
    extends BaseMvvmState<EventArchivingViewModel, EventArchivingSheet> {
  @override
  Widget buildLoadingContentView() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        SizedBox(
          height: 16,
        ),
        CommonText('事件归档', textSize: 18, fontWeight: FontWeight.bold),
        SizedBox(
          height: 20,
        ),
        TitleValueWidget(
                title: '事件可控性',
                value: viewModel.controllable?.name ?? "",
                isRequired: true)
            .onTap(() {
          viewModel.chooseControllable();
        }),
        TitleValueWidget(
                title: '事件等级',
                value: viewModel.gradeLevel?.name ?? "",
                isRequired: true)
            .onTap(() {
          viewModel.chooseGradeLevel();
        }),
        SizedBox().setWeight(1),
        Row(
          children: [
            TextButton(
              onPressed: () {
                Go().pop();
              },
              child: CommonText('取消', textColor: Colours.gray_99),
              style: TextButton.styleFrom(
                  shape:
                      StadiumBorder(side: BorderSide(color: Colours.gray_99))),
            ).setWeight(1),
            SizedBox(width: 20),
            TextButton(
              onPressed: () {
                viewModel.submitArchiving();
              },
              child: CommonText('确定', textColor: Colors.white),
              style: TextButton.styleFrom(
                  shape: StadiumBorder(), backgroundColor: Colors.blue),
            ).setWeight(2),
          ],
        ),
        SizedBox(
          height: 20,
        )
      ],
    ).addToContainer(
        padding: EdgeInsets.symmetric(horizontal: 16),
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.vertical(top: 20.radius)));
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  EventArchivingViewModel createViewModel() {
    return EventArchivingViewModel(context, id: widget.id);
  }

  @override
  void onRetryClick() {}
}
